﻿Imports System.Data.OleDb

Public Class NivelAcademicoService

    Public Function findAllUniversitario() As List(Of NivelAcademico)
        Return findAll("where universitario='1'")
    End Function

    Public Function findAllNoUniversitario() As List(Of NivelAcademico)
        Return findAll("where no_universitario='1'")
    End Function


    Private Function findAll(ByVal where As String) As List(Of NivelAcademico)
        Dim lista As New List(Of NivelAcademico)

        Dim con = contexto.conBD
        Try
            Dim cmd As New OleDbCommand()
            cmd.Connection = con
            con.Open()

            cmd.CommandText = "select * from NivelAcademico " & where
            Dim dr As OleDbDataReader = cmd.ExecuteReader()
            While dr.Read
                Dim e As New NivelAcademico
                e.codigo = dr("codigo").ToString()
                e.nombre = dr("nombre").ToString()
                lista.Add(e)
            End While

        Catch ex As Exception
            MsgBox(ex.ToString)
        Finally
            con.Close()
        End Try

        Return lista
    End Function
End Class
